package com.hzdl.cinema.Service.impl;

import com.hzdl.cinema.Service.StudioService;
import com.hzdl.cinema.dao.StudioDao;
import com.hzdl.cinema.dao.impl.StudioDaoImpl;
import com.hzdl.cinema.domain.Studio;


import java.util.List;

public class StudioServiceImpl implements StudioService {

    StudioDao studioDao = new StudioDaoImpl();

    @Override
    public List<Studio> findAll() {
        List<Studio> studioList = studioDao.findAll();
        return studioList;
    }

    @Override
    public Studio findStudioById(int studioId) {
        Studio studio = studioDao.findStudioById(studioId);
        return studio;
    }

    @Override
    public boolean addStudio(Studio studio) {
        Studio studio01 = studioDao.findStudioByName(studio.getStudioName());
        if (studio01 != null) {
            //演出厅已存在
            return false;
        } else {
            studioDao.addStudio(studio.getStudioName(), studio.getStudioColcount(), studio.getStudioRowcount());
            return true;
        }

    }

    @Override
    public void editStudio(int studioId, Studio studio) {
        Studio studio01 = studioDao.findStudioByName(studio.getStudioName());
        studioDao.editStudio(studioId,studio.getStudioName(), studio.getStudioColcount(), studio.getStudioRowcount());
    }

    @Override
    public void deleteStudioById(int studioId) {
        studioDao.deleteStudioById(studioId);
    }

    @Override
    public Studio searchStudioByName(String studioName) {
        Studio studio=studioDao.searchStudioByName(studioName);
        return studio;
    }
}
